<template>
  <div class="app-container home">
    <table-panel
      ref="tablePanel"
      align="left"
      :table-data="listData"
      :columns="columns"
      :operateArray="operateArray"
      @onOperate="onOperate"
      :pagination="false"
    >
    </table-panel>
  </div>
</template>

<script>
import TablePanel from "@/components/TablePanel/index.vue";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { processList } from "@/api/approvalManage/processManage.js";
import { articulatedProcess } from "@/api/approvalManage/processArticulated.js";
export default {
  name: "nodeIndex",
  components: {
    TablePanel,
  },
  data() {
    return {
      operateArray: [
        {
          name: "关联",
          icon: "table-column-link",
          hasPermi: "['system:post:associated']",
        },
      ],
      columns: [
        {
          field: "businessCode",
          label: "业务类型",
          type: "select",
          disabled: true,
          options: [
            {
              label: "企业展示-图文展示",
              value: "COMPANYSHOW",
            },
            {
              label: "产品货架-图文展示",
              value: "PRODUCTSHOW",
            },
            {
              label: "产品货架-报价方案-上架",
              value: "QUOTEPROJECT-LISTING",
            },
            {
              label: "企业展示-资料管理-上架",
              value: "COMPANYSHOW-DOCUMENT-LISTING",
            },
            {
              label: "产品货架-资料管理-上架",
              value: "PRODUCTSHOW-DOCUMENT-LISTING",
            },
            {
              label: "个人空间-营销方案-上架",
              value: "MARKETING-PROGRAM-LISTING",
            },
            {
              label: "企业展示-资料管理-下架",
              value: "COMPANYSHOW-DOCUMENT-DELIST",
            },
            {
              label: "产品货架-资料管理-下架",
              value: "PRODUCTSHOW-DOCUMENT-DELIST",
            },
            {
              label: "产品货架-报价方案-下架",
              value: "QUOTEPROJECT-DELIST",
            },
            {
              label: "个人空间-营销方案-下架",
              value: "MARKETING-PROGRAM-DELIST",
            },
          ],
        },
        {
          field: "processDefId",
          label: "设置（流程）",
          type: "select",
          options: this.processSelect(),
        },
        {
          label: "操作",
          width: "101px",
        },
      ],
      listData: [
        {
          businessCode: "COMPANYSHOW",
          processDefId: "",
        },
        {
          businessCode: "PRODUCTSHOW",
          processDefId: "",
        },
        {
          businessCode: "QUOTEPROJECT-LISTING",
          processDefId: "",
        },
        {
          businessCode: "COMPANYSHOW-DOCUMENT-LISTING",
          processDefId: "",
        },
        {
          businessCode: "PRODUCTSHOW-DOCUMENT-LISTING",
          processDefId: "",
        },
        {
          businessCode: "MARKETING-PROGRAM-LISTING",
          processDefId: "",
        },
        {
          businessCode: "COMPANYSHOW-DOCUMENT-DELIST",
          processDefId: "",
        },
        {
          businessCode: "PRODUCTSHOW-DOCUMENT-DELIST",
          processDefId: "",
        },
        {
          businessCode: "QUOTEPROJECT-DELIST",
          processDefId: "",
        },
        {
          businessCode: "MARKETING-PROGRAM-DELIST",
          processDefId: "",
        }
      ],
    };
  },

  methods: {
    // 获取流程列表
    processSelect() {
      let arr = [];
      processList({ processDeployStatus: 2 }).then((res) => {
        if (res.rows.length > 0) {
          res.rows.forEach((item) => {
            arr.push({
              label: item.name,
              value: item.id,
            });
          });
        }
      });
      return arr;
    },
    // 操作
    onOperate(type, row) {
      const params = {
        businessCode: row.businessCode,
        processDefId: row.processDefId + "",
      };
      this.$confirm("确定关联吗？").then(() => {
        articulatedProcess(params).then((res) => {
          this.$router.push("/approvalManage/processArticulated");
          this.$message.success("操作成功！");
        });
      });
    },
  },

  mounted() {},
};
</script>

<style scoped lang="scss"></style>
